-
Notifications
You must be signed in to change notification settings - Fork 14
Make locations for detectors dir and models dir configurable. #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Also, from __future__ import annotations
Implement configurable detectors dir and models dir, with default defined in config.py.
Also eliminate the_absolute_current_path module variable (no longer in use).
|
Hi John, |
My testing has been only on Mac. These are actually very easy to sanity-check on any platform that we have access to. LabGym calls config.get_config() very early, and if debug logging is turned on, there is a statement that outputs the config dictionary: Henry/Bobby, how can we do a sanity check on other platforms, for the dict values for key 'detectors' and key 'models'? |
|
I see. Thanks for the clarification. |
|
BTW, when I was exploring PyInstaller, I was wondering if references to file would be evaluated at PyInstaller "compile" time or at LabGym execution time. Fortunately, I was able to confirm that the file references are evaluated at LabGym execution time. |
There are 8 assignments in LabGym code based on LabGym/detectors and LabGym/models directories.
This PR to replace those 8 with assignments based on config (which is defaults to the traditional locations (LabGym/detectors and LabGym/models).
Since the defaults are the traditional locations, this change should produce no behavior change, just a new ability to configure the locations when desired.
The changes are to 4 files:
gui_analyzer.PanelLv2_AnalyzeBehaviors needs models and detectors
gui_categorizer.PanelLv2_GenerateExamples needs detectors
gui_categorizer.PanelLv2_TrainCategorizers needs models
gui_categorizer.PanelLv2_TestCategorizers needs models
gui_detector.PanelLv2_TrainDetectors needs detectors
gui_detector.PanelLv2_TestDetectors needs detectors
Note the existing use expects strings, not pathlib.Path objects.
So either
(a) config.get_config() should return string, not pathlib.Path
objects, or
(b) the 8 assignment statements should convert with str(), or
(c) the assignments and all other downstream manipulations should be
rewritten for pathlib.Path objects.
The least invasive path is (a).
Also,
7. wrote logger.debug statements to shadow the 8 assignments. Since relevant unit tests don't exist, this provides a way to demonstrate that the assignments are executed.
Test results which show that all 8 assignments were executed:
Assignment 1 of 8 is in gui_analyzer.py
Analysis Module --> Analyze Behaviors --> Select a Categorizer ...
2025-09-18 09:34:05 DEBUG [4320867840:LabGym.gui_analyzer:gui_analyzer:253] self.model_path: '/Users/john/Public/LabGym/LabGym/models'
Assignment 2 of 8 is in gui_analyzer.py
Analysis Module --> Analyze Behaviors --> Specify the method to detect animals or objects --> Use trained Detectors (versatile but slow)
2025-09-18 10:20:03 DEBUG [4437001728:LabGym.gui_analyzer:gui_analyzer:564] self.detector_path: '/Users/john/Public/LabGym/LabGym/detectors'
Assignment 3 of 8 is in gui_categorizer.py
Training Module --> Generate Behavior Examples --> Specify the method to detect animals or objects --> Use trained Detectors (versatile but slow)
2025-09-18 10:29:57 DEBUG [4437001728:LabGym.gui_categorizer:gui_categorizer:382] self.detector_path: '/Users/john/Public/LabGym/LabGym/detectors'
Assignment 4 & 5 of 8 are in gui_categorizer.py
Training Module --> Train Categorizers
2025-09-18 09:32:32 DEBUG [4320867840:LabGym.gui_categorizer:gui_categorizer:1087] self.model_path: '/Users/john/Public/LabGym/LabGym/models'
2025-09-18 09:32:32 DEBUG [4320867840:LabGym.gui_categorizer:gui_categorizer:1089] self.path_to_categorizer: '/Users/john/Public/LabGym/LabGym/models/New_model'
Assignment 6 of 8 is in gui_categorizer.py
Training Module --> Test Categorizers
2025-09-18 09:32:35 DEBUG [4320867840:LabGym.gui_categorizer:gui_categorizer:1594] self.model_path: '/Users/john/Public/LabGym/LabGym/models'
Assignment 7 of 8 is in gui_detector.py
Training Module --> Train Detectors
2025-09-18 09:31:58 DEBUG [4320867840:LabGym.gui_detector:gui_detector:246] self.detector_path: '/Users/john/Public/LabGym/LabGym/detectors'
Assignment 8 of 8 is in gui_detector.py
Training Module --> Test Detectors
2025-09-18 09:32:26 DEBUG [4320867840:LabGym.gui_detector:gui_detector:403] self.detector_path: '/Users/john/Public/LabGym/LabGym/detectors'